package util;

import math.Maths;
import static engine.GL.*;
import org.lwjgl.Sys;

public class GLUtil {
    
    private GLUtil() 
    {
    }
    
    public static void consoleEngineCapacity() {
        Util.console("[GL]  LWJGL Version:         " + Sys.getVersion());
        Util.console("[GL]  GPU Vendor:            " + getVendor());
        Util.console("[GL]  GPU Hardware:          " + getGPURenderer());
        Util.console("[GL]  OpenGL Version:        " + getVersion());
        Util.console("[GL]  GLSL Version:          " + getShaderVersion());
        Util.console("[GL]  Vertex Capacity:       " + getVertexCapacity());
        Util.console("[GL]  Light Capacity:        " + getLightCapacity());
        Util.console("[GL]  Multitexture Capacity: " + getMultiTexturingCapacity());
        Util.console("[GL]  Anisotropy Capacity:   " + getAnisotropyCapacity());
        Util.console("[GL]  Max Texture LOD:       " + getLODCapacity());
//        Util.console("[GL]  Dump:                  " + getString(EXTENSIONS));
    }
    
    public static boolean supports(String extension)
    {
        String all = getString(EXTENSIONS);
        return (all.indexOf(extension) >= 0);
    }
    
    public static String getVendor()
    {
        return getString(VENDOR);
    }

    public static String getGPURenderer()
    {
        return getString(RENDERER);
    }

    public static String getVersion()
    {
        return getString(VERSION);
    }

    public static String getShaderVersion()
    {
        return getString(SHADING_LANGUAGE_VERSION);
    }

    public static int getVertexCapacity() 
    {
        return getInteger(MAX_ELEMENTS_VERTICES);
    }

    public static int getLightCapacity() 
    {
        return getInteger(MAX_LIGHTS);
    }

    public static int getMultiTexturingCapacity() 
    {
        return Maths.max(getInteger(MAX_COMBINED_TEXTURE_IMAGE_UNITS), getInteger(MAX_TEXTURE_COORDS));
    }

    public static float getAnisotropyCapacity() 
    {
        return getFloat(MAX_TEXTURE_MAX_ANISOTROPY);
    }

    public static float getLODCapacity() 
    {
        return -getFloat(MAX_TEXTURE_LOD_BIAS);
    }
    
}
